Optimize queries based on Timescale hypertable configuration#511
Open
aditya1702 wants to merge 88 commits intoremove-filteringfrom
Open
Optimize queries based on Timescale hypertable configuration#511aditya1702 wants to merge 88 commits intoremove-filteringfrom
aditya1702 wants to merge 88 commits intoremove-filteringfrom
Conversation
… tests) Bring in BYTEA type definitions, indexer changes, GraphQL schema/resolver updates, processor changes, and test files from opxdr-bytea-2 branch. These files had no modifications on the timescale branch.
…hemas Change hash, account_id, operation_xdr, and address columns from TEXT to BYTEA type while preserving all TimescaleDB hypertable configuration, composite primary keys, and chunk settings.
… statechanges) Convert hash, account_id, operation_xdr, and address columns from TEXT to BYTEA in BatchInsert, BatchCopy, and query methods. Uses HashBytea, AddressBytea, and pgtypeBytesFromNullAddressBytea for type conversions. Preserves TimescaleDB junction table patterns (ledger_created_at columns, composite primary keys, parameter numbering).
Adopt BYTEA types (HashBytea, AddressBytea, XDRBytea, NullAddressBytea) in test data while preserving TimescaleDB-specific patterns: - Keep ledger_created_at in junction table INSERTs - Use generic "duplicate key value violates unique constraint" assertions (TimescaleDB chunk-based constraint names differ from standard PG) - Keep 5-value return from processLedgersInBatch (includes startTime/endTime)
Rename inner err to addrErr in address BYTEA conversion loops to avoid shadowing the outer err variable from pgx.CopyFrom.
Shared helper for appending ledger_created_at >= / <= conditions to query builders. Accepts a column name parameter for table-qualified columns in CTEs. Used by all three BatchGetByAccountAddress methods.
Add *TimeRange parameter to transactions, operations, and state changes BatchGetByAccountAddress. Inserts ledger_created_at >= / <= conditions inside the MATERIALIZED CTE (transactions/operations) or after the account_id WHERE clause (state changes) for early chunk pruning.
Add buildTimeRange helper that validates since <= until and constructs a *data.TimeRange. All three account field resolvers (Transactions, Operations, StateChanges) now build and pass time range to the data layer.
Update GetAccountTransactions, GetAccountOperations, and GetAccountStateChanges client methods with since/until *time.Time parameters. Update corresponding GraphQL query builders to declare $since: Time, $until: Time variables and pass them through. Fix integration test call sites for updated signatures.
Add appendTimeRangeConditions unit tests covering nil, since-only, until-only, both, and table-qualified column cases. Add resolver tests for Transactions, Operations, and StateChanges with time range params: since in past/future, until before since validation error, and combined with pagination/filters. Update existing resolver tests for new since/until method signatures. Fix BatchGetByToID test calls that had extra nil argument.
Resolve 5 conflicts by accepting timescale changes: - Add bloom filter sparse indexes to transactions, operations, state_changes - token_id column as BYTEA (from tokenid-bytea rebase) - Add account_category composite index for state_changes - Enable timescaledb.enable_sparse_index_bloom in docker-compose and test containers Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Combines query optimizations (composite cursors, MATERIALIZED CTEs, time range since/until, decomposed cursor conditions) with account registration removal from remove-filtering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cosmetic changes from gqlgen: import reordering and type declaration formatting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
query-optimize simplified state change account resolution to use AccountID directly from the row, making this method and its type obsolete. Also includes gofumpt formatting fixes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
[TODO: Short statement about what is changing.]
Why
[TODO: Why this change is being made. Include any context required to understand the why.]
Known limitations
[TODO or N/A]
Issue that this PR addresses
[TODO: Attach the link to the GitHub issue or task. Include the priority of the task here in addition to the link.]
Checklist
PR Structure
allif the changes are broad or impact many packages.Thoroughness
Release